package com.xge.component_caipu.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.xge.common_libary.bean.CollectCpEntity

@Dao
interface CollectDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(entity: CollectCpEntity)

    @Update
    suspend fun update(entity: CollectCpEntity)

    @Delete
    suspend fun delete(entity: CollectCpEntity)

    @Query("SELECT * FROM collect_cp")
    suspend fun getAll(): List<CollectCpEntity>

    @Query("SELECT * FROM collect_cp WHERE sid = :id")
    suspend fun getById(id: Int): CollectCpEntity?

    @Query("DELETE FROM collect_cp WHERE sid = :id")
    suspend fun deleteById(id: Int)

    @Query("DELETE FROM collect_cp WHERE sid IN (:ids)")
    suspend fun deleteByIds(ids: List<String>)
}